//
//  ExchgeRateCulTopCell.m
//  CenturyCity
//
//  Created by beisheng03 on 2017/12/22.
//  Copyright © 2017年 beisheng. All rights reserved.
//

#import "ExchgeRateCulTopCell.h"

@interface ExchgeRateCulTopCell ()
@property (weak, nonatomic) IBOutlet UIImageView *leftImageView;
@property (weak, nonatomic) IBOutlet UILabel *leftLabel;
@property (weak, nonatomic) IBOutlet UITextField *rightTextField;

@end

@implementation ExchgeRateCulTopCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.leftLabel.font = MYFONT(16);
    
    self.rightTextField.font = MYFONT(19);
    
    self.leftImageView.image = [UIImage imageNamed:@"PHP"];
    
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(textChange) name:UITextFieldTextDidChangeNotification object:self.rightTextField];


    // Initialization code
}

- (void)setModel:(ExchangRateModel *)model{
    _model = model;
    
    if (_model.name.length > 0) {
        
        self.rightTextField.text = _model.name;
    }
    
    
    
    if ([_model.topImageName isEqualToString:@"CNY"]) {
        
        self.leftLabel.text = @"人民币 ¥";
        
        self.leftImageView.image = [UIImage imageNamed:@"CNY"];
        
    } else if ([_model.topImageName isEqualToString:@"EUR"]){
        
        self.leftLabel.text = @"欧元 €";
        
        self.leftImageView.image = [UIImage imageNamed:@"EUR"];
        
        
    }else if ([_model.topImageName isEqualToString:@"USD"]){
        
        self.leftLabel.text = @"美元 $";
        
        self.leftImageView.image = [UIImage imageNamed:@"USD"];
        
        
    }else if ([_model.topImageName isEqualToString:@"JPY"]){
        
        self.leftLabel.text = @"日元 JPY￥";
        
        self.leftImageView.image = [UIImage imageNamed:@"JPY"];
        
        
    }else if ([_model.topImageName isEqualToString:@"GBP"]){
        
        self.leftLabel.text = @"英镑 ￡";
        
        self.leftImageView.image = [UIImage imageNamed:@"GBP"];
        
        
    }else if ([_model.topImageName isEqualToString:@"HKD"]){
        
        self.leftLabel.text = @"港币 HK$ ";
        
        self.leftImageView.image = [UIImage imageNamed:@"HKD"];
        
        
    }else if ([_model.topImageName isEqualToString:@"PHP"]){
        
        self.leftLabel.text = @"比索 PHP ";
        
        self.leftImageView.image = [UIImage imageNamed:@"PHP"];
        
        
    }else{
        
        self.leftLabel.text = @"";
        
        self.leftImageView.hidden = YES;
        
    }
    
//    self.leftImageView.image = [UIImage imageNamed:_model.topImageName];
}


- (void)textChange{
    
    self.model.name = self.rightTextField.text;
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
